using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Resources;
using System.Globalization;
using LoginWebService;

public partial class _Default : System.Web.UI.Page
{
    LoginWS loginWS;

    protected void Page_Load(object sender, EventArgs e)
    {
        ResourceManager resourceMgr;
        CultureInfo ci;

        initializeServices();

        resourceMgr = ResourceManager.CreateFileBasedResourceManager("Language", @"C:\inetpub\wwwroot\desarrollo\SoinusWeb\Languages", null);
        ci = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);

        this.lblEmail.Text = resourceMgr.GetString("lblEmail",ci);
        this.lblPass.Text = resourceMgr.GetString("lblPass", ci);
        this.btnLogin.Text = resourceMgr.GetString("btnLogin", ci);
        this.lnkFormRegister.Text = resourceMgr.GetString("lnkFormRegister", ci);
    }

    private void initializeServices()
    {
        loginWS = new LoginWS();
    }

    protected void btnLogin_Click(object sender, EventArgs e)
    {        
        Boolean resultado = false;

        string user = tbxEmail.Text;
        string pass = tbxPass.Text;

        resultado = loginWS.AuthenticateUser(user, pass);

        if (resultado)
        {
            this.Session.Add("username", user);
            this.Session.Add("password", pass);
            FormsAuthentication.RedirectFromLoginPage(user, false);
            Response.Redirect("Player.aspx");
        }
    }
}
